package com.ruoyi.pcwl.controller;

import java.util.List;

import com.ruoyi.pcwl.domain.query.ArticleChannelQuery;
import com.ruoyi.pcwl.domain.ArticleChannel;
import com.ruoyi.pcwl.domain.vo.Result;
import com.ruoyi.pcwl.service.ArticleChannelService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * 文章分类频道 Controller
 */

@Api(tags = "文章分类频道控制层")
@RestController("articleChannelController")
@RequestMapping("/articleChannel")
public class ArticleChannelController extends BaseController{

	@Resource
	private ArticleChannelService articleChannelService;

	/**
	 * 取最大编号
	 */
	@ApiOperation("查最大编号")
	@GetMapping("/getMaxNo")
	public Result getMaxNo(){
		return Result.ok(articleChannelService.getMaxNo());
	}


	/**
	 * 根据条件分页查询
	 */
	@ApiOperation("根据条件分页查询")
	@GetMapping("/loadDataList")
	public Result loadDataList(ArticleChannelQuery query){
		return Result.ok(articleChannelService.selectPage(query));
	}

	/**
	 * 新增
	 */
	@ApiOperation("新增")
	@PostMapping("/add")
	public Result add(@RequestBody ArticleChannel bean) {
		articleChannelService.add(bean);
		return Result.ok(null);
	}


	/**
	 * 批量新增
	 */
	@ApiOperation("批量新增")
	@PostMapping("/addBatch")
	public Result addBatch(@RequestBody List<ArticleChannel> listBean) {
		articleChannelService.addBatch(listBean);
		return Result.ok(null);
	}

	/**
	 * 批量新增/修改
	 */
	@ApiOperation("批量新增/修改")
	@PostMapping("/addOrUpdateBatch")
	public Result addOrUpdateBatch(@RequestBody List<ArticleChannel> listBean) {
		articleChannelService.addBatch(listBean);
		return Result.ok(null);
	}

	/**
	 * 根据Id查询对象
	 */
	@ApiOperation("根据Id查询对象")
	@GetMapping("/getArticleChannelById/{id}")
	public Result getArticleChannelById(@PathVariable Long id) {
		return Result.ok(articleChannelService.getArticleChannelById(id));
	}

	/**
	 * 根据Id修改对象
	 */
	@ApiOperation("根据Id修改对象")
	@PutMapping("/updateArticleChannelById/{id}")
	public Result updateArticleChannelById(@RequestBody ArticleChannel bean,@PathVariable Long id) {
		articleChannelService.updateArticleChannelById(bean);
		return Result.ok(null);
	}

	/**
	 * 根据Id删除
	 */

	@ApiOperation("根据Id删除")
	@DeleteMapping("/deleteArticleChannelById/{id}")
	public Result deleteArticleChannelById(@PathVariable Long id) {
		articleChannelService.deleteArticleChannelById(id);
		return Result.ok(null);
	}
}